package com.app.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import com.app.handler.demo.Demo1Handler;
import com.app.handler.demo.Demo2Handler;
import com.app.handler.demo.DemoHandler;
import com.app.handler.demo.TestResultHandler;

/**
 * 样例消费者
 * 
 * @author 北京八维博大科技 薛建新
 * @date 2022年12月22日 13:49:42
 * @Copyright 北京八维博大科技
 */
@Component
public class DemoConsumer {
	private static final String TOPIC_PREFIX = "bj.test.";
	@Autowired
	DemoHandler demoHandler;
	@Autowired
	Demo1Handler demo1Handler;
	@Autowired
	Demo2Handler demo2Handler;
	@Autowired
	TestResultHandler testResultHandler;

//	@KafkaListener(topics = TOPIC_PREFIX + "demo")
	public void demoConsumer(ConsumerRecord<String, String> message, Acknowledgment ack) {
		demoHandler.consumer(message, ack);
	}

	@KafkaListener(topics = TOPIC_PREFIX + "demo1")
	public void demo1Consumer(ConsumerRecord<String, String> message, Acknowledgment ack) {
		demo1Handler.consumer(message, ack);
	}

//	@KafkaListener(topics = TOPIC_PREFIX + "demo2")
	public void demo2Consumer(ConsumerRecord<String, String> message, Acknowledgment ack) {
		demo2Handler.consumer(message, ack);
	}

//	@KafkaListener(topics = TOPIC_PREFIX + "test_result")
	public void testResultConsumer(ConsumerRecord<String, String> message, Acknowledgment ack) {
		testResultHandler.consumer(message, ack);
	}

}
